import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/layout/index-layout'
import Login from '@/views/login/index-login'
import Home from '@/views/home/home'

//点击跳转同一个路径
// 在VueRouter上配置路由跳转，在router中的index.js中加上以下代码，注意加在use之前
const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location) {
    return routerPush.call(this, location).catch(err => {})
};


Vue.use(VueRouter)
export const baseRouters = [
  {
    path: '',
    name: 'index-test',
    component: Layout,
    meta: {
      title: '首页1',
      isLogin: true
    },
    children: [
      {
        path: '/',
        name: 'home',
        component: Home,
        meta: {
          title: '首页2'
        },
      },
    ]
  },
]
export const routes = [

  {
    path: '/login',
    name: 'login-test',
    component: Login
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})



export default router
